﻿// change to using the Decorated/extended Radio and Button
function EatAndDoit() {
    var silver = document.getElementById("silverlight");
    if (silver) {
        var content = silver.Content;
        if (content) {
            var sample = content.Sample;
            if (sample) {
                var eat = sample.EatControl;
                if (eat) {
                    eat.Checked = true;

                    // var doit = sample.DoitControl;
                    // doit.DoClick();

                    sample.ClickDoitControl();
                    // alert(sample.Result);

                    
                    var poll = function() {
                        if (sample.IsProcessing)
                            window.setTimeout(poll, 300);
                        else
                            alert(sample.Result);
                    };

                    window.setTimeout(poll, 500); 


                }
                else
                    alert('Error: could not find EatControl radio control!');
            }
            else
                alert('Error: could not find sample silverlight usercontrol');
        }
        else {
            alert('Error: could not find silverlight content!');
        }
    }
    else {
        alert('Error: Could not found silverlight control');
    }
}
